import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _toLower from "lodash/toLower";
import _toUpper from "lodash/toUpper";
import _upperFirst from "lodash/upperFirst";
import _isUndefined from "lodash/isUndefined";

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _class, _class2;

/**
 *  数据权限维度 __组件
 * @date: 2019-11-26
 */
import React from 'react';
import { Button, Form, Input, Modal, Switch, Table, Tooltip, Row, Col } from 'antd';
import { Bind } from 'lodash-decorators';
import { connect } from 'dva';
import { Button as ButtonPermission } from 'components/Permission';
import { SEARCH_FORM_ROW_LAYOUT, FORM_COL_3_LAYOUT, SEARCH_COL_CLASSNAME, SEARCH_FORM_ITEM_LAYOUT } from 'utils/constants';
import formatterCollections from 'utils/intl/formatterCollections';
import intl from 'utils/intl';
import { CPAAS_IAM } from 'utils/config';
import notification from 'utils/notification';
import { tableScrollWidth } from 'utils/utils';
import { operatorRender, yesOrNoRender } from 'utils/renderer';
import AddDataModal from "./AddDataModal";
/**
 * 使用 Form.Item 组件
 */

var FormItem = Form.Item;
/**
 * 租户级权限管理 - 值集
 * @extends {Component} - React.Component
 * @reactProps {Object} authorityPuragent - 数据源
 * @reactProps {Object} loading - 数据加载是否完成
 * @reactProps {Object} form - 表单对象
 * @reactProps {Function} [dispatch=function(e) {return e;}] - redux dispatch方法
 * @return React.element
 */

var AuthDetail = (_dec = formatterCollections({
  code: ['ciam.authorityManagement']
}), _dec2 = Form.create({
  fieldNameProp: null
}), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec14 = Bind(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(AuthDetail, _React$Component);

  var _super = _createSuper(AuthDetail);

  function AuthDetail(props) {
    var _this;

    _classCallCheck(this, AuthDetail);

    _this = _super.call(this, props);
    _this.state = {
      selectRows: [],
      switchLoading: false,
      addModalVisible: false
    };
    return _this;
  }

  _createClass(AuthDetail, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.fetchData();
    }
    /**
     *查询数据
     *
     * @param {Object} pageData
     */

  }, {
    key: "fetchData",
    value: function fetchData() {
      var pageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props = this.props,
          form = _this$props.form,
          dispatch = _this$props.dispatch,
          roleId = _this$props.roleId,
          userId = _this$props.userId,
          code = _this$props.code,
          _this$props$isSecGrp = _this$props.isSecGrp,
          isSecGrp = _this$props$isSecGrp === void 0 ? false : _this$props$isSecGrp,
          _this$props$secGrpId = _this$props.secGrpId,
          secGrpId = _this$props$secGrpId === void 0 ? '' : _this$props$secGrpId,
          _this$props$isAccount = _this$props.isAccount,
          isAccount = _this$props$isAccount === void 0 ? false : _this$props$isAccount;
      var fieldsValue = form.getFieldsValue();
      var typeCode = code.replace(/([A-Z])/, '_$1');
      var payload = isSecGrp ? {
        secGrpId: secGrpId,
        roleId: roleId
      } : {
        roleId: roleId,
        userId: userId
      };
      dispatch({
        type: "".concat(isSecGrp ? isAccount // isAccount=true 证明来源子账户管理-分配安全组
        ? "accSecGrpAuthority" : "secGrpAuthority" : !_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/fetchAuthority").concat(_upperFirst(code)),
        payload: _objectSpread(_objectSpread(_objectSpread({}, payload), fieldsValue), {}, {
          authorityTypeCode: code === 'valueList' ? 'LOV' : code === 'dataSource' ? _toUpper(code) : code === 'purorg' ? 'PURCHASE_ORGANIZATION' : code === 'puragent' ? 'PURCHASE_AGENT' : _toUpper(typeCode)
        }, pageData)
      });
    }
    /**
     * 添加数据
     * @param {Aarray} addRows 选择的数据
     */

  }, {
    key: "addValueList",
    value: function addValueList(addRows) {
      var _this2 = this;

      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          _this$props2$roleData = _this$props2.roleDataAuthority.head,
          head = _this$props2$roleData === void 0 ? {} : _this$props2$roleData,
          roleId = _this$props2.roleId,
          userId = _this$props2.userId,
          code = _this$props2.code;
      var typeCode = code.replace(/([A-Z])/, '_$1');
      var obj = !_isUndefined(roleId) ? {
        roleAuthData: head,
        roleAuthDataLineList: addRows
      } : {
        userAuthority: head,
        userAuthorityLineList: addRows
      };
      dispatch({
        type: "".concat(!_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/addAuthority").concat(_upperFirst(code)),
        payload: _objectSpread({
          authorityTypeCode: code === 'valueList' ? 'LOV' : code === 'dataSource' ? _toUpper(code) : code === 'purorg' ? 'PURCHASE_ORGANIZATION' : code === 'puragent' ? 'PURCHASE_AGENT' : _toUpper(typeCode),
          roleId: roleId,
          userId: userId
        }, obj)
      }).then(function (response) {
        if (response) {
          _this2.onHideAddModal();

          notification.success();

          _this2.refresh();
        }
      });
    }
    /**
     *删除方法
     */

  }, {
    key: "remove",
    value: function remove() {
      var _this3 = this;

      var _this$props3 = this.props,
          dispatch = _this$props3.dispatch,
          roleId = _this$props3.roleId,
          userId = _this$props3.userId,
          code = _this$props3.code;
      var selectRows = this.state.selectRows;

      var onOk = function onOk() {
        dispatch({
          type: "".concat(!_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/deleteAuthority").concat(_upperFirst(code)),
          payload: {
            userId: userId,
            roleId: roleId,
            deleteRows: selectRows
          }
        }).then(function (response) {
          if (response) {
            _this3.refresh();

            notification.success();
          }
        });
      };

      Modal.confirm({
        title: intl.get('cpaas.common.message.confirm.remove').d('确定删除选中数据？'),
        onOk: onOk
      });
    }
    /**
     *刷新
     */

  }, {
    key: "refresh",
    value: function refresh() {
      this.fetchData();
      this.setState({
        selectRows: []
      });
    }
    /**
     * 表格勾选
     * @param {null} _ 占位
     * @param {object} selectedRow 选中行
     */

  }, {
    key: "onSelectChange",
    value: function onSelectChange(_, selectedRows) {
      this.setState({
        selectRows: selectedRows
      });
    }
    /**
     * 展示弹出框
     */

  }, {
    key: "onShowAddModal",
    value: function onShowAddModal() {
      this.setState({
        addModalVisible: true
      });
    }
    /**
     * 隐藏弹出框
     */

  }, {
    key: "onHideAddModal",
    value: function onHideAddModal() {
      this.setState({
        addModalVisible: false
      });
    }
    /**
     *点击查询按钮事件
     */

  }, {
    key: "queryValue",
    value: function queryValue() {
      this.fetchData();
      this.setState({
        selectRows: []
      });
    }
    /**
     *分页change事件
     */

  }, {
    key: "handleTableChange",
    value: function handleTableChange() {
      var pagination = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      this.fetchData({
        page: pagination
      });
    }
    /**
     * 表单重置
     */

  }, {
    key: "handleFormReset",
    value: function handleFormReset() {
      var form = this.props.form;
      form.resetFields();
    }
    /**
     *点击加入全部后触发事件
     *
     * @param {Boolean} checked switch的value值
     */

  }, {
    key: "includeAllFlag",
    value: function includeAllFlag(checked) {
      var _this4 = this;

      var _this$props4 = this.props,
          code = _this$props4.code,
          dispatch = _this$props4.dispatch,
          roleId = _this$props4.roleId,
          userId = _this$props4.userId,
          _this$props4$roleData = _this$props4.roleDataAuthority.head,
          head = _this$props4$roleData === void 0 ? {} : _this$props4$roleData;
      this.setState({
        switchLoading: true
      });
      var typeCode = code.replace(/([A-Z])/, '_$1');
      var obj = !_isUndefined(roleId) ? {
        roleAuthData: _objectSpread(_objectSpread({}, head), {}, {
          includeAllFlag: checked ? 1 : 0
        }),
        roleAuthDataLineList: []
      } : {
        userAuthority: _objectSpread(_objectSpread({}, head), {}, {
          includeAllFlag: checked ? 1 : 0
        }),
        userAuthorityLineList: []
      };
      dispatch({
        type: "".concat(!_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/addAuthority").concat(_upperFirst(code)),
        payload: _objectSpread({
          authorityTypeCode: code === 'valueList' ? 'LOV' : code === 'dataSource' ? _toUpper(code) : code === 'purorg' ? 'PURCHASE_ORGANIZATION' : code === 'puragent' ? 'PURCHASE_AGENT' : _toUpper(typeCode),
          roleId: roleId,
          userId: userId
        }, obj)
      }).then(function (response) {
        if (response) {
          _this4.refresh();

          notification.success();

          _this4.setState({
            switchLoading: false
          });
        }
      });
    }
    /**
     *渲染查询结构
     *
     * @returns
     */

  }, {
    key: "renderForm",
    value: function renderForm() {
      var _this5 = this;

      var getFieldDecorator = this.props.form.getFieldDecorator;
      var _this$props5 = this.props,
          name = _this$props5.name,
          isSecGrp = _this$props5.isSecGrp;
      var secGrpFormLayout = {
        labelCol: {
          span: 12
        },
        wrapperCol: {
          span: 12
        }
      };
      return /*#__PURE__*/React.createElement(Form, null, isSecGrp ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Row, Object.assign({
        type: "flex",
        gutter: 24,
        align: "bottom"
      }, SEARCH_FORM_ROW_LAYOUT), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get('ciam.authorityManagement.model.authorityManagement.code', {
          name: name
        }).d("".concat(name, "\u4EE3\u7801"))
      }, secGrpFormLayout), getFieldDecorator('dataCode')( /*#__PURE__*/React.createElement(Input, {
        trim: true,
        inputChinese: false
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get('ciam.authorityManagement.model.authorityManagement.name', {
          name: name
        }).d("".concat(name, "\u540D\u79F0"))
      }, secGrpFormLayout), getFieldDecorator('dataName')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({}, FORM_COL_3_LAYOUT, {
        className: SEARCH_COL_CLASSNAME
      }), /*#__PURE__*/React.createElement(FormItem, null, /*#__PURE__*/React.createElement(Button, {
        style: {
          marginRight: 8
        },
        onClick: this.handleFormReset
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        onClick: function onClick() {
          return _this5.queryValue();
        },
        htmlType: "submit"
      }, intl.get('cpaas.common.button.search').d('查询')))))) : /*#__PURE__*/React.createElement(Row, {
        type: "flex",
        align: "bottom",
        gutter: 24
      }, /*#__PURE__*/React.createElement(Col, {
        span: 8
      }, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.authorityManagement.model.authorityManagement.code', {
          name: name
        }).d("".concat(name, "\u4EE3\u7801"))
      }), getFieldDecorator('dataCode')( /*#__PURE__*/React.createElement(Input, {
        trim: true,
        inputChinese: false
      })))), /*#__PURE__*/React.createElement(Col, {
        span: 8
      }, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.authorityManagement.model.authorityManagement.name', {
          name: name
        }).d("".concat(name, "\u540D\u79F0"))
      }), getFieldDecorator('dataName')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, {
        span: 8
      }, /*#__PURE__*/React.createElement(FormItem, SEARCH_FORM_ITEM_LAYOUT, /*#__PURE__*/React.createElement(Button, {
        style: {
          marginRight: 8
        },
        onClick: this.handleFormReset
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        onClick: function onClick() {
          return _this5.queryValue();
        },
        htmlType: "submit"
      }, intl.get('cpaas.common.button.search').d('查询'))))));
    }
    /**
     * 屏蔽/取消屏蔽安全组数据权限
     * @param {object} record - 表格行数据
     */

  }, {
    key: "handleShield",
    value: function handleShield(record) {
      var secGrpDclLineId = record.secGrpDclLineId,
          shieldFlag = record.shieldFlag;
      var _this$props$onShield = this.props.onShield,
          onShield = _this$props$onShield === void 0 ? function (e) {
        return e;
      } : _this$props$onShield;
      var shieldData = {
        shieldFlag: shieldFlag,
        authorityId: secGrpDclLineId,
        authorityType: 'DCL'
      };
      onShield(shieldData, this.fetchData);
    }
  }, {
    key: "render",
    value: function render() {
      var _this6 = this;

      var _this$props6 = this.props,
          _this$props6$roleData = _this$props6.roleDataAuthority,
          roleDataAuthority = _this$props6$roleData === void 0 ? {} : _this$props6$roleData,
          name = _this$props6.name,
          code = _this$props6.code,
          roleId = _this$props6.roleId,
          userId = _this$props6.userId,
          organizationId = _this$props6.organizationId,
          addLoading = _this$props6.addLoading,
          fetchLoading = _this$props6.fetchLoading,
          shieldLoading = _this$props6.shieldLoading,
          _this$props6$isSecGrp = _this$props6.isSecGrp,
          isSecGrp = _this$props6$isSecGrp === void 0 ? false : _this$props6$isSecGrp,
          _this$props6$isShow = _this$props6.isShow,
          isShow = _this$props6$isShow === void 0 ? true : _this$props6$isShow;
      var _roleDataAuthority$li = roleDataAuthority.list,
          list = _roleDataAuthority$li === void 0 ? [] : _roleDataAuthority$li,
          _roleDataAuthority$he = roleDataAuthority.head,
          head = _roleDataAuthority$he === void 0 ? {} : _roleDataAuthority$he,
          _roleDataAuthority$pa = roleDataAuthority.pagination,
          pagination = _roleDataAuthority$pa === void 0 ? {} : _roleDataAuthority$pa;
      var typeCode = code.replace(/([A-Z])/, '-$1');
      var _this$state = this.state,
          switchLoading = _this$state.switchLoading,
          addModalVisible = _this$state.addModalVisible,
          selectRows = _this$state.selectRows;
      var columns = [!_isUndefined(roleId) && !(code === 'purorg' || code === 'puragent') && !isSecGrp && {
        title: intl.get('cpaas.common.model.common.tenantId').d('租户'),
        dataIndex: 'tenantName',
        width: 200
      }, {
        title: intl.get('ciam.authorityManagement.model.authorityManagement.code', {
          name: name
        }).d("".concat(name, "\u4EE3\u7801")),
        dataIndex: 'dataCode',
        width: 300
      }, {
        title: intl.get('ciam.authorityManagement.model.authorityManagement.name', {
          name: name
        }).d("".concat(name, "\u540D\u79F0")),
        dataIndex: 'dataName'
      }, isSecGrp && isShow && {
        dataIndex: 'shieldFlag',
        title: intl.get('ciam.authorityManagement.model.authorityManagement.isShield').d('是否屏蔽'),
        width: 90,
        render: yesOrNoRender
      }, isSecGrp && isShow && {
        key: 'operator',
        title: intl.get('cpaas.common.button.action').d('操作'),
        width: 100,
        fixed: 'right',
        render: function render(_, record) {
          var operators = [];
          var shieldBtn = {
            key: 'shield',
            ele: /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              onClick: function onClick() {
                return _this6.handleShield(record);
              }
            }, record.shieldFlag ? intl.get('ciam.authorityManagement.view.button.cancelShield').d('取消屏蔽') : intl.get('ciam.authorityManagement.view.button.shield').d('屏蔽')),
            len: record.shieldFlag ? 4 : 2,
            title: record.shieldFlag ? intl.get('ciam.authorityManagement.view.button.cancelShield').d('取消屏蔽') : intl.get('ciam.authorityManagement.view.button.shield').d('屏蔽')
          };
          operators.push(shieldBtn);
          return operatorRender(operators);
        }
      }].filter(Boolean);
      var addModalOptions = {
        defaultFlag: true,
        rowKey: 'dataId',
        title: intl.get('ciam.authorityManagement.model.authorityManagement.select', {
          name: name
        }).d("\u9009\u62E9".concat(name)),
        lov: {
          lovTypeCode: 'URL',
          valueField: 'dataId',
          displayField: 'dataName',
          tableFields: columns,
          queryFields: [{
            label: intl.get('ciam.authorityManagement.model.authorityManagement.code', {
              name: name
            }).d("".concat(name, "\u4EE3\u7801")),
            field: 'dataCode'
          }, {
            label: intl.get('ciam.authorityManagement.model.authorityManagement.name', {
              name: name
            }).d("".concat(name, "\u540D\u79F0")),
            field: 'dataName'
          }],
          queryUrl: "".concat(CPAAS_IAM, "/v1/").concat(organizationId, "/").concat(_isUndefined(roleId) ? 'users' : 'role', "/").concat(_isUndefined(roleId) ? userId : roleId, "/data/").concat(code === 'valueList' ? 'lov' : code === 'dataSource' ? _toLower(code) : _toLower(typeCode)).concat(code === 'dataGroup' ? '' : 's')
        },
        confirmLoading: addLoading,
        modalVisible: addModalVisible,
        onHideAddModal: this.onHideAddModal,
        addData: this.addValueList
      };
      var rowSelection = isSecGrp ? null : {
        onChange: this.onSelectChange,
        selectedRowKeys: selectRows.map(function (n) {
          return n.dataId;
        })
      };
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
        className: "table-list-search"
      }, this.renderForm()), !isSecGrp && /*#__PURE__*/React.createElement("div", {
        style: {
          textAlign: 'right'
        }
      }, !head.includeAllFlag && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonPermission, {
        style: {
          margin: '0 8px 16px 0'
        },
        onClick: this.onShowAddModal
      }, intl.get("ciam.authority.view.button.table.create.valueList").d('新建权限')), /*#__PURE__*/React.createElement(ButtonPermission, {
        style: {
          margin: '0 8px 16px 0'
        },
        disabled: selectRows.length <= 0,
        onClick: function onClick() {
          return _this6.remove();
        }
      }, intl.get("ciam.authority.view.button.table.delete.valueList").d('删除权限'))), /*#__PURE__*/React.createElement("div", {
        style: {
          display: 'inline-block',
          margin: '0 8px 16px 0'
        }
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          marginRight: '8px'
        }
      }, intl.get('ciam.authority.view.message.label').d('加入全部:')), /*#__PURE__*/React.createElement(Tooltip, {
        title: intl.get('ciam.authority.view.message.title.tooltip.vl').d('“加入全部”即将所有值集权限自动添加至当前账户，无需再手工添加。'),
        placement: "right"
      }, /*#__PURE__*/React.createElement(Switch, {
        loading: switchLoading || fetchLoading,
        checked: !!head.includeAllFlag,
        onChange: this.includeAllFlag
      })))), /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "dataId",
        loading: isSecGrp ? shieldLoading || fetchLoading : fetchLoading,
        dataSource: list,
        rowSelection: rowSelection,
        pagination: pagination,
        columns: columns,
        scroll: {
          x: tableScrollWidth(columns)
        },
        onChange: this.handleTableChange
      }), /*#__PURE__*/React.createElement(AddDataModal, addModalOptions));
    }
  }]);

  return AuthDetail;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "fetchData", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "fetchData"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "addValueList", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "addValueList"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "remove", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "remove"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "refresh", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "refresh"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "onSelectChange", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "onSelectChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "onShowAddModal", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "onShowAddModal"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "onHideAddModal", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "onHideAddModal"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "queryValue", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "queryValue"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleTableChange", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleTableChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleFormReset", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "handleFormReset"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "includeAllFlag", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "includeAllFlag"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleShield", [_dec14], Object.getOwnPropertyDescriptor(_class2.prototype, "handleShield"), _class2.prototype)), _class2)) || _class) || _class);

function mapStateToProps(state, props) {
  var loading = state.loading;
  var code = props.code,
      roleId = props.roleId,
      _props$isSecGrp = props.isSecGrp,
      isSecGrp = _props$isSecGrp === void 0 ? false : _props$isSecGrp,
      _props$isAccount = props.isAccount,
      isAccount = _props$isAccount === void 0 ? false : _props$isAccount;
  var temp = "".concat(isSecGrp ? isAccount ? "accSecGrpAuthority" : "secGrpAuthority" : !_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code));
  return {
    roleDataAuthority: state[temp],
    addLoading: loading.effects["".concat(!_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/addAuthority").concat(_upperFirst(code))],
    fetchLoading: loading.effects["".concat(isSecGrp ? isAccount ? "accSecGrpAuthority" : "secGrpAuthority" : !_isUndefined(roleId) ? 'roleDataAuthority' : 'authority').concat(_upperFirst(code), "/fetchAuthority").concat(_upperFirst(code))],
    shieldLoading: loading.effects['roleManagement/shieldSecGrpPermission'] || loading.effects['roleManagement/cancelShieldSecGrpPermission']
  };
}

function mapDispatchToProps(dispatch) {
  return {
    dispatch: dispatch
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(AuthDetail);